﻿using Qlab.SharedKernel.Parameters;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace Qlab.SharedKernel.Interfaces
{
    public interface IRepository
    {
        Task<T> GetByIdAsync<T>(int id) where T : BaseEntity, IAggregateRoot;

        Task<List<T>> QueryAsync<T>(Expression<Func<T, bool>> predicate = null) where T : BaseEntity, IAggregateRoot;

        Task AddAsync<T>(T entity) where T : BaseEntity, IAggregateRoot;

        Task DeleteAsync<T>(T entity) where T : BaseEntity, IAggregateRoot;

        Task UpdateAsync<T>(T entity) where T : BaseEntity, IAggregateRoot;

        Task<(int, List<TSource>)> PageListAsync<TSource, TKey>(PageListParameter<TSource, TKey> parameter) where TSource : BaseEntity, IAggregateRoot;

        Task ExecuteTransAsync(Action<IRepository> action);
    }
}